<?php
/*
Plugin Name: WP e-Commerce - Facebook Share
Plugin URI: http://www.visser.com.au/wp-ecommerce/plugins/facebook-share/
Description: Enables visitors to your WP e-Commerce store to share Product pages on their Facebook Wall.
Version: 1.4.5
Author: Visser Labs
Author URI: http://www.visser.com.au/about/
License: GPL2
*/

load_plugin_textdomain( 'wpsc_fs', null, dirname( plugin_basename( __FILE__ ) ) . '/languages' );

include_once( 'includes/functions.php' );

include_once( 'includes/common.php' );

switch( wpsc_get_major_version() ) {

	case '3.7':
		include_once( 'includes/release-3_7.php' );
		break;

	case '3.8':
		include_once( 'includes/release-3_8.php' );
		break;

}

$wpsc_fs = array(
	'filename' => basename( __FILE__ ),
	'dirname' => basename( dirname( __FILE__ ) ),
	'abspath' => dirname( __FILE__ ),
	'relpath' => basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ )
);

$wpsc_fs['prefix'] = 'wpsc_fs';
$wpsc_fs['name'] = __( 'Facebook Share for WP e-Commerce', 'wpsc_fs' );
$wpsc_fs['menu'] = __( 'Facebook Share', 'wpsc_fs' );

if( is_admin() ) {

	include_once( 'includes/install.php' );
	register_activation_hook( __FILE__, 'wpsc_fs_install' );

	include_once( dirname( __FILE__ ) . '/includes/update.php' );

	function wpsc_fs_html_page() {

		global $wpsc_fs;

		$action = wpsc_get_action(); ?>
<div id="profile-page" class="wrap">
	<div id="icon-options-general" class="icon32"><br /></div>
	<h2><?php echo $wpsc_fs['menu']; ?></h2>
<?php
		switch( $action ) {

			case 'update':
				$position = $_POST['position'];
				$display_productspage = $_POST['display_productspage'];
				$display_singleproduct = $_POST['display_singleproduct'];
	
				update_option( 'wpsc_fs_position', $position );
				update_option( 'wpsc_fs_display_productspage', $display_productspage );
				update_option( 'wpsc_fs_display_singleproduct', $display_singleproduct );
	
				$message = __( 'Settings saved', 'wpsc_fs' );
				$output = '<div class="updated settings-error"><p><strong>' . $message . '</strong></p></div>';
				echo $output;
	
				wpsc_fs_options_form();
				break;

			default:
				wpsc_fs_options_form();
				break;

		} ?>
</div>
<?php
	}

	function wpsc_fs_options_form() {

		$positions = wpsc_productpage_positions();

		$position = get_option( 'wpsc_fs_position' );
		$display_productspage = get_option( 'wpsc_fs_display_productspage' );
		$display_singleproduct = get_option( 'wpsc_fs_display_singleproduct' );

		include( 'templates/admin/wpsc-fs_admin_settings.php' );

	}

} else {

	include_once( 'includes/template.php' );
	include_once( 'includes/legacy.php' );

	$position = get_option( 'wpsc_fs_position' );
	if( $position )
		add_action( $position, 'wpsc_fs_init' );
	else
		add_action( 'wpsc_product_addons', 'wpsc_fs_init' );

	function wpsc_fs_print_styles() {

		wp_register_script( 'fb_share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share' );
		wp_enqueue_script( 'fb_share' );

	}
	add_action( 'wp_print_styles', 'wpsc_fs_print_styles' );

}
?>